package com.test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class test6 {

    public static void main(String[] args) throws InterruptedException {
        Runnable r=new Runnable() {
            @Override
            public void run() {
                System.out.println("来了");
            }
        };
        ExecutorService theadPool= Executors.newFixedThreadPool(100);
        for (int i=1;i<10;i++){
            Thread t=new Thread(r);
            theadPool.execute(t);  //同时执行
        }

        theadPool.shutdown(); //不是把所有线程停止，就不会开启新的线程
        //等待线程池所有线程执行完了，才会执行下面的代码
        theadPool.awaitTermination(1, TimeUnit.MINUTES);
        System.out.println("这是最后执行的");


    }

}
